package org.moonlight.jvm.instructions.conversions.i2x;

import org.moonlight.jvm.instructions.base.NoOperandsInstruction;
import org.moonlight.jvm.rtda.exclusive.Frame;
import org.moonlight.jvm.rtda.exclusive.OperandStack;

/**
 * I2B: 从 操作数栈栈顶 弹出一个 int型变量, 将 int型变量 强转为 byte型，然后再作为int型压入操作数栈
 *
 * @author Moonlight
 * @createTime 2023/8/23 14:36
 **/
public class I2B extends NoOperandsInstruction {

    @Override
    public void execute(Frame frame) {
        OperandStack stack = frame.getOperandStack();
        int val = stack.popInt();
        byte b = (byte)val;
        stack.pushInt(b);
    }

}
